<template>
	<view class="content">
		<button @click="init">初始化</button>
		<button @click="login">登录</button>
		<button @click="logout">登出</button>
		<button @click="authorize">顶部授权</button>
	</view>
</template>

<script>
	import {
		initAlbc,
		loginAlbc,
		logoutAlbc,
		topAuthAlbc
	} from '@/uni_modules/wen-uts-albc';

	export default {
		created() {
			this.init()
		},
		methods: {
			async init() {
				const {
					result,
					fail
				} = await initAlbc();
				console.log(fail|| result)
				uni.showToast({
					title: fail || result,
					icon: 'none'
				});
			},
			async login() {
				const {
					result,
					fail
				} = await loginAlbc();
				uni.showToast({
					title: fail || result,
					icon: 'none'
				});
			},
			async logout() {
				const {
					result,
					fail
				} = await logoutAlbc();
				uni.showToast({
					title: fail || result,
					icon: 'none'
				});
			},
			async authorize() {
				const query = {
					icon: "	https://foruda.gitee.com/avatar/1677214859156121124/10605975_du-jiwen_1660208658.png!avatar200",
					name: "授权App名称",
					appkey: "34487880"
				};
				const {
					result,
					fail
				} = await topAuthAlbc(query);
				if (fail) {
					uni.showToast({
						title: fail,
						icon: 'none'
					});
				} else {
					uni.showToast({
						title: result,
						icon: 'none'
					});
				}
			}
		}
	};
</script>